package com.example.gch.hellolamedemo;

import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

import java.io.File;

public class MainActivity extends AppCompatActivity {
    public static final String FILE_MP4 = "thunder.wav";
    public static final String FILE_DST = "converted.mp3";
    LAMEUtil lameUtil = new LAMEUtil();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final TextView textView = (TextView) findViewById(R.id.tv);
        textView.setText("正在转码，请在控制台查看进度");
        new WorkThread().start();
    }

    class WorkThread extends Thread {
        @Override
        public void run() {
            File srcFile = new File(Environment.getExternalStorageDirectory(), FILE_MP4);
            File dstFile = new File(Environment.getExternalStorageDirectory(), FILE_DST);
            String srcPath = srcFile.getAbsolutePath();
            String dstPath = dstFile.getAbsolutePath();
            lameUtil.convertmp3(srcPath, dstPath);
        }
    }

}
